import React from 'react';
import * as lodash from 'lodash';
import {Button, Checkbox, message, Select, Radio } from 'antd';
const RadioGroup = Radio.Group;
import {WeaDialog, WeaSearchGroup, WeaFormItem, WeaInput, WeaSelect, WeaBrowser, WeaCheckbox, WeaHelpfulTip} from 'ecCom';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import EField_New from './base/EField_New';
import EOrderCol from './base/EOrderCol';
import EPicturesSettings from './base/EPicturesSettings';
import './Style_7.css';
// ecode自定义元素数据来源
class Content_ecodeElement_DataSource extends React.Component {

    state = {
        id: this.props.tabData.id,
        title: this.props.tabData.title || '',
        boundID: this.props.tabData.boundID || '',
        moreUrl: this.props.tabData.moreUrl || '',
    };

    constructor(props) {
        super(props);
        this.getButtons = this.getButtons.bind(this);
        this.onOk = this.onOk.bind(this);
        this.onCancel = this.onCancel.bind(this);
    }

    render() {
        const {title} = this.state;
        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@s65rwm`}
                className="portal-esetting-dialog portal-news-esetting-dialog"
                visible={true}
                title={getLabel(19480, '内容设置')}
                icon="icon-coms-portal"
                iconBgcolor='#1a57a0'
                style={{width: 660, height: 507}}
                hasScroll={true}
                buttons={this.getButtons()}
                onCancel={this.onCancel}
            >
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@1h7b5u`} title={getLabel(33396, '设置项')} needTigger={true} showGroup={true}>
                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@31w7hw`} label={getLabel(24986, '标题')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                        <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@l3ks7j`} inputType="multilang" isBase64={true} value={title} viewAttr={3} onChange={value => this.setState({title: value})}/>
                    </WeaFormItem>
                </WeaSearchGroup>
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@01sgbd`} title={getLabel(127253, '来源设置')} needTigger={true} showGroup={true}>
                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@2ib8od`} label={'ecode boundID'} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                        <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@g78i1u`}
                            value={this.state.boundID}
                            onChange={value => {
                                this.setState({boundID: value});
                            }}
                        />
                    </WeaFormItem>

                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@yjzohp`} label={'more地址'} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                        <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@lpi561`}
                            value={this.state.moreUrl}
                            onChange={value => {
                                this.setState({moreUrl: value});
                            }}
                        />
                    </WeaFormItem>
                </WeaSearchGroup>
            </WeaDialog>

        );
    }

    getButtons() {
        let buttons = [];
        buttons.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@vryyj1`} type="primary" onClick={this.onOk}>{getLabel(826, '确定')}</Button>);
        buttons.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ccyut8`} type="ghost" onClick={this.onCancel}>{getLabel(31129, '取消')}</Button>);
        return buttons;
    }

    onOk() {
        if (!this.state.title) {
            message.warning(getLabel(15859, '必要信息不完整！'));
        } else {
            this.props.onOk(this.state);
        }
    }

    onCancel() {
        this.props.onCancel();
    }
}

export default Content_ecodeElement_DataSource;
